package cn.tedu.sp04.order.service;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ItemClientFB implements ItemClient {
    @Override
    public JsonResult<List<Item>> getItems(String orderId) {
        //模拟缓存数据
        if (Math.random()<0.5){
            ArrayList<Item> items = new ArrayList<>();
            items.add(new Item(1,"商品1", 23));
            items.add(new Item(2,"商品2", 845));
            items.add(new Item(3,"商品3", 238));
            items.add(new Item(4,"商品4", 76));
            items.add(new Item(5,"商品5", 232));
            items.add(new Item(6,"商品6", 875));
            return JsonResult.ok().data(items);
        }
        //没有缓存返回缓存数据
        return JsonResult.err("无法获取订单商品列表");
    }

    @Override
    public JsonResult decreaseNumber(List<Item> items) {

        return JsonResult.err("无法修改商品库存");
    }
}
